<!DOCTYPE html>
<html  lang="zh-CN">
<head>
  <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  <meta content=always name=referrer>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="format-detection" content="telephone=no"/>
  <meta name="keywords" content=""/>
  <meta name="description" content=""/>
  <link rel="stylesheet" type="text/css" href="__STATIC__/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="__STATIC__/css/base.css">
  <script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
  <script src="__STATIC__/js/jquery-1.11.3.min.js"></script>
  <script src="__STATIC__/layer/layer.js"></script>
  <script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
  <title>找回密码</title>
</head>
<body style="background: #FAFAFA;">
<div class="wrap">
  <div class="find_pass">
    <div class="logo">
      <a href="/"><img src="__STATIC__/img/logo_ishop.png" style="width: 150px;height:80px;"></a>
    </div>
    <div class="find_content">
      <div class="find_title">找回密码</div>
      <ul class="list_find_cate">
        <li>01/<span>输入登录名</span></li>
        <li  class="active">02/<span>验证信息</span></li>
        <li>03/<span>重置密码</span></li>
      </ul>
      <div class="find_step">
        <div class="tips">
          请向你的手机号码<span>{$username}</span>发送验证码，请在下方输入：
        </div>
        <form action="" method="post" id="form">
        <div class="input-group">
          <label class="label_con">手机验证码：</label>
          <div class="send_mes">
            <input type="text" name="code" placeholder="&nbsp;验证码" datatype="n4" nullmsg="请填写验证码" errormsg="验证码输入错误哦！！！">
            <label id="code"><a href="javascript:check_num();" id="yzm">获取验证码</a></label>
          </div>
        </div>
        <div class="input-group">
          <input type="submit" class="submit" value="下一步" id="sub">
        </div>
        </form>

      </div>
      <!--<div class="hotline">上述方法无法找回?  红红来帮助你：       拨打客服热线：<span>4005-5447865252</span></div>-->

    </div>
  </div>
</div>
</body>
<script>
  $(function () {
    $.Tipmsg.r = null;
    $.Tipmsg.p = null;
    $.Datatype.n4 = /^\d{6}$/;
    $("#form").Validform({
      tiptype: function (msg) {
        layer.msg(msg);
      },
      btnSubmit: '#sub',
      tipSweep: true,
      // ajax 提交
      ajaxPost:true,
      callback: function (t) {
        if (t.code == 200) {
          layer.msg(t.message);
//          layer.load(3);
          setTimeout(function(){
            layer.closeAll('loading');
            // 跳转页面
            location.href = "{:url('shop/login/edit_password')}";
          }, 3000);

        }else {
          layer.msg(t.message);
        }

      }
    });
  });


  function check_num() {
    var tel = '';

    tel = "{$username}";

    if (tel == '') {
      layer.msg('请输入手机号！');
      return false;
    }
    if (!(/^1(3|4|5|7|8)\d{9}$/.test(tel))) {
      layer.msg('手机号格式不正确！');
      return false;
    }

    count_down();
    $.ajax({
      url: "{:url('shop/login/getVerif')}",
      dataType: 'json',
      type: 'post',
      data: {'tel': tel,'act':'pc_forget'},
      success: function (t) {
        if (t.code != 200) {
          layer.msg(t.message);
          setTimeout(function () {
            location.href = "{:url('shop/login/edit_password')}";
          }, 2000);
        }
      }
    })
  }

  //验证码倒计时
  function count_down() {
    var num = 5;
    var verif = $('#yzm');
    var timer = setInterval(function () {
      verif.text(num + '秒');
      if (num <= 60 && num >= 1) {
        verif.removeAttr('href');
      } else {
        verif.text('再次获取');
        window.clearInterval(timer);
        verif.attr("href", 'javascript:check_num();');
      }
      num--;
    }, 1000);
  }
</script>
</html>